#ifndef GAMEENGINE_GRAPHICS_TEXTURE_TEXTURE1D_H
#define GAMEENGINE_GRAPHICS_TEXTURE_TEXTURE1D_H

#include <GameEngine/Graphics/graphics_settings.h>

#include <GameEngine/Graphics/graphic_resource.h>
#include <GameEngine/Graphics/Texture/texture_defs.h>
#include <GameEngine/Core/Color/color_rgb.h>


#ifdef GAMEENGINE_NAMESPACES
namespace GameEngine {
#endif

//=================================================================================


//! Wrapper for OpenGL one-dimensional textures
/*!
 *  This class defines wrapper functions to one-dimensional OpenGL textures, which
 *  provides convenient ways to manipulate them. Still, this class limits the types
 *  of operations that can be performed on textures, since it does not reproduces the
 *  whole interface provided by the OpenGL library. If client code requires some
 *  specific usage for the textures, low-level OpenGL calls have to be made (the OpenGL
 *  identifier of the texture can be accessed using the id() function).
 *
 *  The textures are handled as resources, which allows them to be quickly and safely
 *  copied / deleted.
 *
 @note This class must always be manipulated AFTER a valid OpenGL context has been created. If
       no OpenGL context is available, any call to any function or constructor of this class
	   will result in an application crash.
 */
class _Graphics_decl Texture1d : public GraphicResource {
	GAMEENGINE_DECLARE_RTTI_PARENT(Texture1d,GraphicResource)
	//! The resource manager class is friend of the 1D texture class because it must be able to access its ID and context
	friend class ResourceManager<ID,CONTEXTID>;

public:
	Texture1d();
	Texture1d(const Texture1d& rhs);
	virtual ~Texture1d();
	Texture1d& operator=(const Texture1d& rhs);

	bool initialized() const;

	bool bind_texture(bool enable_texturing=false) const;
	bool unbind_texture(bool disable_texturing=false) const;

	bool set_parameters(Texture::ApplicationMode mode);
	bool set_parameters(Texture::WrapMode mode);
	bool set_parameters(Texture::MagnifyingFilter filter);
	bool set_parameters(Texture::MinifyingFilter filter);
	bool set_parameters(Texture::MipmapMode mipmap);

	Texture::TextureInternalFormat get_format() const;
	Texture::ApplicationMode get_application_mode() const;
	Texture::MagnifyingFilter get_magnifying_filter() const;
	Texture::MinifyingFilter get_minifying_filter() const;
	Texture::MipmapMode get_mipmap_mode() const;
	Texture::TextureSize get_width() const;

	bool set_texture(ColorRGB* colors, Texture::TextureSize width, Texture::TextureInternalFormat format = Texture::RGBInternalFormat);
	bool set_texture(ColorRGBA* colors, Texture::TextureSize width, Texture::TextureInternalFormat format = Texture::RGBAInternalFormat);

	ID id() const;

private:
	void clean_id();
	void create_id();

	virtual void destroy_resource() const;
	virtual CONTEXTID context() const;
	virtual ID reference() const;

private:
	ID id_;
};

#ifdef GAMEENGINE_NAMESPACES
} // namespace GameEngine
#endif

#endif
